function newSms(data) {
    var time = 5000;
    var position = 'rb';
    if (data.msg_position) {
        position = data.msg_position;
    }
    if (undefined !=　data.msg_show) {
        time = data.msg_show;
    }
    layer.open({
        type: 2,
        title: false,
        closeBtn: true,
        shade: 0,
        area: ['340px', '215px'],
        offset: position,
        time: time,
        shift: 2,
        content: ['../sms/sms.html'],
        success: function(obj, index) {
            var body = layer.getChildFrame('body', index);
            body.find('b').html("消息标题：" + data.msg_title);
            body.find('#msg_info').html(data.msg_info);
        }
    });
}
function onCentent(obj) {
    var socket = io(obj.workman.shost + ':' + obj.workman.socket_port);
    socket.on('connect',
    function() {
        socket.emit('home_login', obj.uid, obj.mark);
    });
    socket.on('update_user_money',
    function(update_user_money) {
        $("#user_money").html(update_user_money);
        if ($('#leftFrame')[0]) $("#leftFrame").contents().find("#smoney").html(update_user_money);
    });
    socket.on('update_user_sms',
    function(update_user_sms) {
        $("#online").html(update_user_sms);
        if (update_user_sms > 0) {
            socket.on('user_sms_msg',
            function(user_sms_msg) {
                if (user_sms_msg) newSms(user_sms_msg);
            });
        }
    });
    socket.on('asyn_login',
    function(asyn_login) {
        if (asyn_login) {
            location.reload();
        }
    });
}
function onUser(obj) {
    var socket = io(obj.workman.shost + ':' + obj.workman.socket_port);
    socket.on('connect',
    function() {
        socket.emit('home_login', obj.uid, obj.mark);
    });
    socket.on('update_user_money',
    function(update_user_money) {
        $(".balance").html(update_user_money);
    });
    socket.on('user_sms_msg',
    function(user_sms_msg) {
        if (user_sms_msg) newSms(user_sms_msg);
    });
}
function onAgent(obj) {
    var socket = io(obj.workman.shost + ':' + obj.workman.socket_port);
    socket.on('connect',
    function() {
        socket.emit('home_login', obj.uid, obj.mark);
    });
    socket.on('update_user_money',
    function(update_user_money) {
        $(".balance").html(update_user_money);
    });
    socket.on('user_sms_msg',
    function(user_sms_msg) {
        if (user_sms_msg) newSms(user_sms_msg);
    });
}